﻿// using Microsoft.International.Converters.TraditionalChineseToSimplifiedConverter;
using OpenCCNET;
using System;

namespace FastTextDemo
{
    class Program
    {
        static string PredictLanguage(string text)
        {
            var language = "en";
            var result = FastTextHelper.PredictLanguage(text);
            if (result.Probability > 0.5)
            {
                language = result.Label.Replace("__label__", "");
                if(language == "zh")
                {
                    // var convertToSimplified = ChineseConverter.Convert(text, ChineseConversionDirection.TraditionalToSimplified);
                    ZhConverter.Initialize();
                    var convertToSimplified = ZhConverter.HantToHans(text);

                    if (text == convertToSimplified)
                    {
                        return "zh-CN";
                    }
                    else
                    {
                        return "zh-TW";
                    }
                }
            }
            return language;
        }

        static void Main(string[] args)
        {
            var language = PredictLanguage("幫我查詢下是什麽原因");
            Console.WriteLine("Hello World!");
        }
    }
}
